let meauId = localStorage.getItem("meauId");
$.ajax({
  url: "/recipe/" + meauId,
  method: "get",
  success(res) {
    // console.log(res);
    const str = `
    <div class="container flex-box">
<div class="left">
  <img src="http://124.223.14.236:3001/public/food/list-${res.data.id}.jpg" alt="" />
</div>
<div class="right">
  <h3>${res.data.name}</h3>
  <p>${res.data.description}</p>
  <h5>下面列表是菜谱中美味的菜品哦！</h5>
</div>
</div>
    `;
    $(".flex-box").html(str);
  },
});

$.ajax({
  method: "get",
  url: "/recipeInfo",
  data: {
    recipe_id: meauId,
  },
  success(res) {
    console.log(res);
    const str1 = res.data
      .map((item) => {
        return `
    <li>
    <a href="detail.html" data-id="${item.id}"</a>
      <img src="http://124.223.14.236:3001/public/${item.img}" alt="" />
      <h3>${item.title}</h3>
    </a>
  </li>
  `;
      })
      .join("");
    $(".list-box").html(str1);
  },
});
$(".list-box").on("click", "a", function (e) {
  let id = $(this).attr("data-id");
  localStorage.setItem("cpid", id);
});
